package repository

import (
	"go-backend-simple-scaffold/global"
	"go-backend-simple-scaffold/model/entity"
)

type UserRepository struct {
}

func (ur *UserRepository) FindByUsername(userName string) (*entity.GbssUser, error) {
	var user entity.GbssUser
	err := global.GBSS_DB.Where("user_name = ?", userName).First(&user).Error
	if err != nil {
		return nil, err
	}
	return &user, nil
}

func (ur *UserRepository) Create(user *entity.GbssUser) error {
	err := global.GBSS_DB.Create(user).Error
	return err
}
